package com.sl.plugin.step.json;

import com.sl.core.engine.meta.ProcessCompDescriptorService;
import com.sl.core.engine.meta.impl.AbstractProcessCompDescriptor;
import com.sl.core.engine.meta.row.ProcessRowDescriptor;
import com.sl.core.engine.meta.valuemeta.ValueMetaArray;
import com.sl.core.engine.meta.valuemeta.ValueMetaObject;
import lombok.Getter;

import java.util.Map;

/**
 *
 */
@Getter
public class JsonGroupByCompDescriptor extends AbstractProcessCompDescriptor<
        JsonGroupByComp, JsonGroupByCompContext> implements ProcessCompDescriptorService {


    @Override
    public void loadDescriptor(Map<String, Object> map) {

    }


    @Override
    public ProcessRowDescriptor getResultDescriptor(ProcessRowDescriptor rowDescriptor) {
        String fieldCode = getStrAttr("fieldCode");
        ValueMetaObject valueMetaObject = new ValueMetaObject(fieldCode);
        ValueMetaArray valueMetaArray = new ValueMetaArray();
        valueMetaArray.setFields(rowDescriptor.getValueMetaList());
        valueMetaObject.addField(valueMetaArray);
        ProcessRowDescriptor iValueMetas = new ProcessRowDescriptor();
        iValueMetas.addValueMeta(valueMetaObject);
        return new ProcessRowDescriptor(iValueMetas);

    }

}
